-
Notifications
You must be signed in to change notification settings - Fork 32
Implement scantxoutset method and test #164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
63e4f61
to
67b03b6
Compare
Why is there identical code in the v17 and v18 |
They basically work the same way, the difference is in their return type, v18 has an additional field ( |
Bro I explained this to you already on the other two PRs you did. Perhaps go back over them and see if you can work it out. |
oh, I now understand, I was looking at how For this recent push, I removed the repeated code across all versions having different fields in their type. |
67b03b6
to
43c8b61
Compare
Oh well that would explain your confusion, the |
Done in #169. FTR bugs happen, if you see things that are wrong or look weird just ask (or PR to fix them). Apologies for being so fierce yesterday. |
Returns column needs updating (and Notes). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Holy moly you picked a difficult one. I'm going to have to come back to this when I can put more thought into it. Feel free to ignore my suggestions until then.
No problem. I will do this going forward. |
Noted! |
Noted.... |
43c8b61
to
9b7f019
Compare
for the notes, is there any need to change it? since it describes perfectly that the scantxoutset is experimental. |
9b7f019
to
1a3bd20
Compare
Oh you are right, lets leave the notes as they are. |
1a3bd20
to
901bf21
Compare
Man this method is really not that simple to add support for because it changes so often. Can we put this one on hold until you've got a few more easy ones done? |
Understood... sure, let's do that. |
901bf21
to
1bcfa84
Compare
Complete the |
types/src/model/blockchain.rs
Outdated
} | ||
|
||
#[derive(Deserialize, Debug, Clone, PartialEq)] | ||
pub struct ScanTxOutSetStatus { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Observation: This struct never changes
Use git grep -A 4 'pub struct ScanTxOutSetStatus'
to see.
} | ||
|
||
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] | ||
pub struct ScanTxOutSetStart { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks wrong. Perhaps add #[serde(deny_unknown_fields)]
to all your structs and that will help find the bugs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added #[serde(deny_unknown_fields)]
to this to test, and there are two missing fields, success
and searched_items
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You've done a bunch of work, well done. This one is pretty curly, here are some ideas.
I think it would be more simple if we were to split up the return types for the three different commands (start, abort, status). That way we only have to re-implement the ones that change.
In the client I think it would be more simple to have three methods, one for each command and not have a ScanAction
type.
Instead of ScanObject
I think we can just use a String
and ignore the added complexity of an object (the WithDesc
variant) since it is unused. In general we don't want to add code to the client that we do not use in testing.
That should give you a bit to work on!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some missing renames, relates to issue #298. I haven't necessarily highlighted all of them.
4c0d8c7
to
22d3d22
Compare
This suggestion is much better. Will work with it. Thank you. |
7d0db23
to
9fa612d
Compare
Split single return type to three types Rename some fields for readability Rename some fields for readability
936dc46
to
678a371
Compare
Implemented suggested changes. |
Format code
678a371
to
52d9d1c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made a few comments, they apply to all affected versions.
@@ -19,7 +19,8 @@ use crate::types::v29::*; | |||
|
|||
#[rustfmt::skip] // Keep public re-exports separate. | |||
pub use crate::client_sync::{ | |||
v17::{AddNodeCommand, ImportMultiRequest, ImportMultiScriptPubKey, ImportMultiTimestamp, Input, Output, SetBanCommand, WalletCreateFundedPsbtInput,}, | |||
v17::{AddNodeCommand, ImportMultiRequest, ImportMultiScriptPubKey, ImportMultiTimestamp, Input, Output, SetBanCommand, WalletCreateFundedPsbtInput |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: This change is unrelated and wrong. It's not fixed by cargo fmt due to the skip above the block.
NB. I'm ok with the random fix being in this PR if done correctly though.
|
||
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] | ||
pub struct ScanTxOutSetAbort(pub bool); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs rustdocs
#[derive(Deserialize, Debug, Clone, PartialEq)] | ||
pub struct ScanTxOutSetStatus { | ||
/// Approximate percent complete | ||
pub progress: f64, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#[derive(Deserialize, Debug, Clone, PartialEq)] | |
pub struct ScanTxOutSetStatus { | |
/// Approximate percent complete | |
pub progress: f64, | |
} | |
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] | |
pub struct ScanTxOutSetStatus(pub f64); |
Also needs docs. Was there a reason serialize was not included that I have missed?
|
||
let _: Option<ScanTxOutSetStatus> = node.client.scan_tx_out_set_status().expect("scantxoutset status"); | ||
|
||
let model: Result<mtype::ScanTxOutSetStart, ScanTxOutSetError> = json.into_model(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moving this line to directly below let json
makes more sense. I had to look twice and first thought the model for ..Status was being checked and not ..Start.
pub total_amount: Amount, | ||
} | ||
|
||
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] | |
/// Unspents item returned as part of `scantxoutset` | |
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] |
Needs docs, e.g. above. Having scanned through the code a lot recently I find it useful if the original RPC is mentioned.
} | ||
|
||
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] | ||
pub struct ScanTxOutSetStart { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added #[serde(deny_unknown_fields)]
to this to test, and there are two missing fields, success
and searched_items
.
/// > Returns an object containing various state info regarding blockchain processing. | ||
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] | ||
#[serde(deny_unknown_fields)] | ||
pub struct GetBlockchainInfo { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of the changes to this file are not part of this PR, left over from a copy and paste from v19?
The JSON-RPC method
scantxoutset
does return a type. We want to test this to catch any changes in behavior in future Core versions.This PR adds a client function that errors if the return value is anything other than the type it returns, along with an integration test that calls this function.
Ref: #116
Closes #115